﻿<div class="page-title">
    Upload Information
</div>

<div class="title-company-arrows editable" ng-show="!portfolioHandler.isRenamingPortfolioName" ng-click="portfolioHandler.changeIsRenaming()" style="word-break: break-all;">{{portfolioHandler.portfolioName}}</div>
<div ng-show="portfolioHandler.isRenamingPortfolioName">
    <input type="text" class="editable-title-inp" ng-model="portfolioHandler.newPortfolioName" />
    <div class="editable-title-buttons">
        <button class="editable-title-save" ng-disabled=" portfolioHandler.newPortfolioName.length > 100 " ng-click="portfolioHandler.renamePortfolio(portfolioHandler.newPortfolioName)"></button>
        <button class="editable-title-clear" ng-click="portfolioHandler.changeIsRenaming()"></button>
    </div>
    <div class="clear"></div>
</div>

<div class="text-danger">
    {{portfolioHandler.portfolioInvalidMatchesCount}} securities not matched
</div>

<div class="table">
    <div class="table-row">
        <div class="table-head width_130">
            <a href="" ng-click="portfolioHandler.setOrderByColInvalid('DisplayInfo.CustomSecurityIdentifierName');" ng-class="portfolioHandler.orderByColInvalid === 'DisplayInfo.CustomSecurityIdentifierName' ? (portfolioHandler.orderByAscInvalid ? 'sortable_up' : 'sortable_down') : null">Security Name</a>
        </div>
        <div class="table-head width_130">
            <a href="" ng-click="portfolioHandler.setOrderByColInvalid('DisplayInfo.SecurityIdentifier');" ng-class="portfolioHandler.orderByColInvalid === 'DisplayInfo.SecurityIdentifier' ? (portfolioHandler.orderByAscInvalid ? 'sortable_up' : 'sortable_down') : null">Security ID</a>
        </div>
        <div class="table-head width_130">
            <a href="" ng-click="portfolioHandler.setOrderByColInvalid('SecurityWeight');" ng-class="portfolioHandler.orderByColInvalid === 'SecurityWeight' ? (portfolioHandler.orderByAscInvalid ? 'sortable_up' : 'sortable_down') : null">Security Weight</a>
        </div>
        <div class="table-row">

            <div class="table-head width_290" ">
                <a href="" ng-click="portfolioHandler.setOrderByColInvalid('CompanyNameLowercase');" ng-class="portfolioHandler.orderByColInvalid === 'CompanyNameLowercase' ? (portfolioHandler.orderByAscInvalid ? 'sortable_up' : 'sortable_down') : null">Potential Matches</a>
            </div>
            <div class="table-head width_200">
                <a href="" ng-click="portfolioHandler.setOrderByColInvalid('MatchedInfo.CapitalIQId');" ng-class="portfolioHandler.orderByColInvalid === 'MatchedInfo.CapitalIQId' ? (portfolioHandler.orderByAscInvalid ? 'sortable_up' : 'sortable_down') : null">Matched ID</a>
            </div>
            <div class="table-head center-align width_290">
                <a href="">Action</a>
            </div>
        </div>
    </div>
    <div class="{{$index % 2==1 ? 'table-row odd': 'table-row'}}" ng-repeat="item in portfolioHandler.portfolioInvalidMatchesList">

        <div class="table-cell width_130" ng-class="{'last':$last}" style="border-left: 1px solid #e0e0e0;">
            {{item.displayInfo.customSecurityIdentifierName}}
        </div>

        <div class="table-cell width_130" ng-class="{'last':$last}">
            {{item.displayInfo.securityIdentifier}}
        </div>

        <!--edit securityWeight-->
        <div class="table-cell width_200">
            <div class="editable" ng-class="{'last':$last}" data-ng-attr-id="objId" ng-show="!portfolioHandler.isChangingSecurityWeight(item.id)" ng-click="portfolioHandler.editSecurityWeight(item.id, item.securityWeight, false)" style="word-break: break-all;">{{item.securityWeight || "&nbsp"}}</div>
            <div ng-show="portfolioHandler.isChangingSecurityWeight(item.id)">
                <input type="text" class="editable-title-inp-small" ng-model="portfolioHandler.updatedSecurityWeightValue" />
                <div class="editable-title-buttons">
                    <button class="editable-title-save" ng-click="portfolioHandler.updateSecurityWeight(item.id, item)"></button>
                    <button class="editable-title-clear" ng-click="portfolioHandler.doneEditSecurityWeight()"></button>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        <!--end edit-->

        <div  class="{{$index % 2==1 ? 'table-row odd': 'table-row'}}" ng-repeat="matchItem in item.matchedInfo">

            <div ng-show="portfolioHandler.companyHasSecurity(matchItem)" class="table-cell width_290" ng-class="{'last':$last}">
                <div ng-if="!item.isAccesible">
                    {{matchItem.companyName}}
                </div>
            </div>

            <div ng-show="portfolioHandler.companyHasSecurity(matchItem)" class="table-cell width_200" ng-class="{'last':$last}">
                {{matchItem.capitalIQId}}
            </div>

            <div ng-show="portfolioHandler.companyHasSecurity(matchItem)" class="table-cell center-align width_290" ng-class="{'last':$last}">
                <button ng-show="portfolioHandler.clientHasAccess(matchItem)" class="add-to-matches-image" ng-click="portfolioHandler.addSecurityToMatched(matchItem.portfolioMatchId, matchItem)"></button>
                <a href="" ng-show="portfolioHandler.clientHasAccess(matchItem)" ng-click="portfolioHandler.addSecurityToMatched(matchItem.portfolioMatchId, matchItem)" style="margin-right: 10px;">Add to Matched</a>
                <div ng-show="!portfolioHandler.clientHasAccess(matchItem)">
                    <div>No access</div>
                </div>
            </div>
            <div ng-show="!portfolioHandler.companyHasSecurity(matchItem)" class="table-cell width_710" >
                No potential matches found
            </div>
        </div>
       
    </div>
</div>

<paging class="left-content"
        page="portfolioHandler.currentInvalidMatchesPage"
        page-size="portfolioHandler.pageSize"
        total="portfolioHandler.portfolioInvalidMatchesCount"
        paging-action="portfolioHandler.getInvalidMatches(page)">
</paging>
<div class="clear">&nbsp;</div>

<div class="matches-company-search top-gray-right">
    <div class="sarch-top" ng-controller="CompanySearchController">
        <div class="sustainalytics-searchbox" data-searchbox-service="CompanySearchBoxServiceAdapter" data-searchbox-text="companySearch.searchData">
            <input type="text" class="inp-search sustainalytics-searchbox-input" style="float: left;" ng-model="search.searchData" placeholder="Search Company...">
            <input type="button" class="btn-search" style="float: left;" onclick="$('.inp-search:first').focus()" ng-click="search.search(false)">
            <div class="clear">&nbsp;</div>
            <div class="search-results-matches" ng-show="search.isVisible">
                <div  style="height: 200px; overflow: auto;" ng-show="search.lastItemsCount > 0 || search.lastSkip > 0">
                    <div  ng-repeat="item in search.items" ng-init="item.markedContent = $parent.search.getMarkedString(item.companyName, $parent.search.searchData)">
                        <div class="marked-content" ng-bind-html="item.markedContent">
                        </div>
                        <div class="add-to-matches">
                            <button value="Add" class="add-to-matches-image" ng-click="portfolioHandler.addCompanyToPortfolioMatches(item)"></button>
                        </div>
                    </div>
               
                </div>
                <p style="text-align: center; color: white; font-weight: bold; padding:0 0 20px 0;" ng-show="search.lastSkip == 0 && search.lastItemsCount == 0">
                    No matches found
                </p>
            </div>
        </div>
        <div class="clear">&nbsp;</div>
    </div>
    <div class="top-gray-right-menu">
        <ul></ul>
    </div>
    <div class="clear">&nbsp;</div>
</div>
<div class="clear">&nbsp;</div>

<div>
    {{portfolioHandler.portfolioValidMatchesCount}} securities successfully matched
</div>

<div class="table">
    <div class="table-row">
        <div class="table-head width_290" style="width: 500px;">
            <a href="" ng-click="portfolioHandler.setOrderByColValid('DisplayInfo.CustomSecurityIdentifierName');" ng-class="portfolioHandler.orderByColValid === 'DisplayInfo.CustomSecurityIdentifierName' ? (portfolioHandler.orderByAscValid ? 'sortable_up' : 'sortable_down') : null">Security Name</a>
        </div>
        <div class="table-head width_290" style="width: 500px;">
            <a href="" ng-click="portfolioHandler.setOrderByColValid('DisplayInfo.SecurityIdentifier');" ng-class="portfolioHandler.orderByColValid === 'DisplayInfo.SecurityIdentifier' ? (portfolioHandler.orderByAscValid ? 'sortable_up' : 'sortable_down') : null">Security ID</a>
        </div>
        <div class="table-head width_200" style="width: 500px;">
            <a href="" ng-click="portfolioHandler.setOrderByColValid('SecurityWeight');" ng-class="portfolioHandler.orderByColValid === 'DisplayInfo.SecurityWeight' ? (portfolioHandler.orderByAscValid ? 'sortable_up' : 'sortable_down') : null">Security Weight</a>
        </div>
        <div class="table-head width_290" style="width: 500px;">
            <a href="" ng-click="portfolioHandler.setOrderByColValid('CompanyNameLowercase');" ng-class="portfolioHandler.orderByColValid === 'CompanyNameLowercase' ? (portfolioHandler.orderByAscValid ? 'sortable_up' : 'sortable_down') : null">Matched Company Name</a>
        </div>
        <div class="table-head width_200">
            <a href="" ng-click="portfolioHandler.setOrderByColValid('MatchedInfo.CapitalIQId');" ng-class="portfolioHandler.orderByColValid === 'MatchedInfo.CapitalIQId' ? (portfolioHandler.orderByAscValid ? 'sortable_up' : 'sortable_down') : null">Matched ID</a>
        </div>
        <div class="table-head center-align width_290">
            <a href="">Action</a>
        </div>
    </div>
    <div class="{{$index % 2==1 ? 'table-row odd': 'table-row'}}" ng-repeat="item in portfolioHandler.portfolioValidMatchesList">
        <div class="table-cell width_290" ng-class="{'last':$last}" style="border-left: 1px solid #e0e0e0;">
            {{item.displayInfo.customSecurityIdentifierName}}
        </div>

        <div class="table-cell width_290" ng-class="{'last':$last}" style="width: 210px;">
            {{item.displayInfo.securityIdentifier}}
        </div>

        <!--edit securityWeight-->
        <div class="table-cell width_200" ng-class="{'last':$last}" style="width: 210px;">
            <div class="editable" data-ng-attr-id="objId" ng-show="!portfolioHandler.isChangingSecurityWeight(item.id)" ng-click="portfolioHandler.editSecurityWeight(item.id, item.securityWeight, true)" style="word-break: break-all;">{{item.securityWeight || "&nbsp"}}</div>
            <div ng-show="portfolioHandler.isChangingSecurityWeight(item.id)">
                <input type="text" class="editable-title-inp-small" ng-model="portfolioHandler.updatedSecurityWeightValue" />
                <div class="editable-title-buttons-small">
                    <button class="editable-title-save" ng-click="portfolioHandler.updateSecurityWeight(item.id, item)"></button>
                    <button class="editable-title-clear" ng-click="portfolioHandler.doneEditSecurityWeight()"></button>
                </div>
                <div class="clear"></div>
            </div>
        </div>
        <!--end edit-->

        <div class="table-cell width_290" ng-class="{'last':$last}" style="width: 210px;">
            <div ng-if="item.isAccesible">
                <a target="_blank" href="#/research/overview/{{item.companyNameUrlFriendly}}">{{item.matchedInfo.companyName}}</a>
            </div>

            <div ng-if="!item.isAccesible">
                {{item.matchedInfo.companyName}}
            </div>
        </div>
        <div class="table-cell width_200" ng-class="{'last':$last}">
            {{item.matchedInfo.capitalIQId}}
        </div>

        <div class="table-cell center-align width_290" ng-class="{'last':$last}">
            <button value="Remove" class="delete-sel-large" ng-click="portfolioHandler.removePortfolioMatch(item.id)"></button>
            <a href="" ng-click="portfolioHandler.removePortfolioMatch(item.id)" style="margin-right: 10px;">Remove</a>
        </div>
    </div>
</div>

<paging class="left-content"
        page="portfolioHandler.currentValidMatchesPage"
        page-size="portfolioHandler.pageSize"
        total="portfolioHandler.portfolioValidMatchesCount"
        paging-action="portfolioHandler.getValidMatches(page)">
</paging>
<div class="clear">&nbsp;</div>

<br />
<button class="btn-green" ng-click="portfolioHandler.closeDialog()">Cancel Import</button>
<button class="btn-green" ng-disabled="portfolioHandler.portfolioValidMatchesCount == 0" ng-click="portfolioHandler.downloadPortfolioMatchedSecurities()">Import Matched</button>
